<?
	if($_GET) {
		@require_once(str_replace('ajax','',dirname(__FILE__)) . "functions.php");
		$offset = drizzo_global_options('timezone_offset');
		$timestamp = gmmktime($_GET['current_hour'],$_GET['current_min'],00,$_GET['month'],$_GET['current_day'],$_GET['current_year']);
		for($i = 8; $i < 15; $i++) { // Get the start of DST for the year of the timestamp
			if(gmdate('w',gmmktime(2 + $offset,0,0,3,$i,gmdate('Y',$timestamp))) == 0) {
				$dst_start = gmmktime(2 + $offset,0,0,3,$i,gmdate('Y',$timestamp));
			}
		}
		for($i = 25; $i < 32; $i++) { // Get the end of DST for the year of the timestamp
			if(gmdate('w',gmmktime(2 + $offset,0,0,11,$i,gmdate('Y',$timestamp))) == 0) {
				$dst_end = gmmktime(2 + $offset,0,0,11,$i,gmdate('Y',$timestamp));
			}
		}
		if($dst_start <= $timestamp && $timestamp <= $dst_end) { // If the timestamp is in DST adjust the offset
			$offset++;
		}
		$dropdowns .= "<select name=\"" . $_GET['name_prefix'] . "date_day\" id=\"" . $_GET['name_prefix'] . "date_day_dropdown\" class=\"date_select\">";
		for($i = 1; $i <= gmdate('t', gmmktime(gmdate('H') + drizzo_global_options('timezone_offset'), gmdate('i'), gmdate('s'), $_GET['month'], gmdate('d'), $_GET['current_year'])); $i++) {
			$i = str_pad($i, 2, "0", STR_PAD_LEFT);
			$d = gmdate('j', gmmktime(gmdate('H') + $offset, gmdate('i'), gmdate('s'), gmdate('m'), $i, $_GET['current_year']));
			if((gmdate('d') == $i && !isset($_GET['current_day'])) || $i == $_GET['current_day']) {
				$dropdowns .= "<option value =\"$i\" selected>$d</option>";
			} else {
				$dropdowns .= "<option value =\"$i\">$d</option>";
			}
		}
		$dropdowns .= "</select>\n";
		echo $dropdowns;
	}
?>
